package com.pgeneral.user.management.service.impl;

import com.pgeneral.user.management.exception.MyException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

import com.pgeneral.user.management.dao.UserDepartmentinfoMapper;
import com.pgeneral.user.management.entity.UserDepartmentInfo;
import com.pgeneral.user.management.service.UserDepartmentinfoService;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserDepartmentinfoServiceImpl implements UserDepartmentinfoService {

    @Resource
    private UserDepartmentinfoMapper dao;


    @Override
    @Transactional(rollbackFor = Exception.class)
    public int batchInsert(List<UserDepartmentInfo> info) {
        if (info == null || info.size() == 0) {
            throw new MyException("1001", "传递的参数为空");
        }
        return dao.batchInsert(info);
    }

    @Override
    public List<UserDepartmentInfo> getDepartmentinfoTable(UserDepartmentInfo departmentinfo) {
        return dao.getDepartmentinfoTable(departmentinfo);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateDepartmentinfoTable(List<UserDepartmentInfo> departmentInfos) {
        return dao.updateDepartmentinfoTable(departmentInfos);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteInfo(List<String> departmentIds) {
        return dao.deleteInfo(departmentIds);
    }

}
